 export function formatTimeDifference(timestamp) {
    const now = new Date().getTime(); // 当前时间的时间戳
    const diffMs = now - timestamp; // 时间差（毫秒）

    // 将时间差转换为秒、分钟、小时、天、月
    const diffSeconds = Math.floor(diffMs / 6000);
    const diffMinutes = Math.floor(diffSeconds / 60);
    const diffHours = Math.floor(diffMinutes / 60);
    const diffDays = Math.floor(diffHours / 24);
    const diffMonths = Math.floor(diffDays / 30); // 假设一个月为30天

    if (diffMinutes < 1) {
        return "一分钟";
    } else if (diffHours < 1) {
        return `${diffMinutes}分钟`;
    } else if (diffDays < 1) {
        return `${diffHours}小时`;
    } else if (diffDays < 30) {
        return `${diffDays}天`;
    } else if (diffMonths < 3) {
        return `${diffMonths}月`;
    } else {
        return null;
    }
}

// 示例使用
const exampleTimestamp = new Date().getTime() - 5 * 60 * 1000; // 5分钟前的时间戳
console.log(formatTimeDifference(exampleTimestamp)); // 输出 "5分钟"

export function gotoHome(){
	uni.showModal({
		title:"提示",
		content:"页面有误将返回首页",
		showCancel:false,
		success: (res) => {
			if(res.confirm){
				uni.reLaunch({
					url:"/pages/index/index"
				})
			}
		}
	})
}